import os
import subprocess


def git_pull():
    """
    图床 git 备份
    :return:
    """
    inputStr = 'git pull'
    work_dir = os.getcwd()
    print(work_dir)
    os.chdir("D:/Pictures/picurl/picurl")
    with open('D:/test.txt', "w+") as file:
        subprocess_popen = subprocess.Popen(inputStr, stdout=subprocess.PIPE)
        if subprocess_popen.stdout is None:
            return
        else:
            curling = subprocess_popen.stdout.readline()
            while curling != b'':
                print(curling)
                curling = subprocess_popen.stdout.readline()
            subprocess_popen.wait()
            print(subprocess_popen.returncode)
    # popen = os.popen(inputStr)
    # print(popen.read())


if __name__ == '__main__':
    git_pull()
    input("请输入：")
